<?php
/**
 * Slince music finder library
 * @author Tao <taosikai@yeah.net>
 */
namespace Slince\MusicFinder;

use GuzzleHttp\Client as HttpClient;

abstract class HttpAwareFinder implements FinderInterface
{
    /**
     * The http client
     * @var HttpClient
     */
    protected $httpClient;

    public function __construct(HttpClient $httpClient = null)
    {
        $httpClient && $this->setHttpClient($httpClient);
    }

    /**
     * @return HttpClient
     */
    public function getHttpClient()
    {
        if (!is_null($this->httpClient)) {
            return $this->httpClient;
        }
        return $this->httpClient = new HttpClient([
            'verify' => false
        ]);
    }

    /**
     * @param HttpClient $httpClient
     * @return HttpAwareFinder
     */
    public function setHttpClient($httpClient)
    {
        $this->httpClient = $httpClient;
        return $this;
    }
}